package com.msb;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Objects;

/// 资源管理
public class ResourceMgr {
    public static BufferedImage goodTankL, goodTankR, goodTankU, goodTankD;
    public static BufferedImage badTankL, badTankR, badTankU, badTankD;
    public static BufferedImage BulletL, BulletR, BulletU, BulletD;
    public static BufferedImage[] explodes = new BufferedImage[16];

     /// classloader

    static {
        try {
            goodTankU = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("com/msb/Images/GoodTank1.png"));
            goodTankL = com.mashibing.tank.ImageUtil.rotateImage(goodTankU,-90);
            goodTankR = com.mashibing.tank.ImageUtil.rotateImage(goodTankU,90);
            goodTankD = com.mashibing.tank.ImageUtil.rotateImage(goodTankU,180);

            badTankU = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("com/msb/Images/BadTank1.png"));
            badTankL = com.mashibing.tank.ImageUtil.rotateImage(badTankU,-90);
            badTankR = com.mashibing.tank.ImageUtil.rotateImage(badTankU,90);
            badTankD = com.mashibing.tank.ImageUtil.rotateImage(badTankU,180);
//            tankL = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("com/msb/Images/GoodTank1.gif"));
//            tankR = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("com/msb/Images/tankR.gif"));
//            tankU = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("com/msb/Images/tankU.gif"));
//            tankD = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("com/msb/Images/tankD.gif"));

            BulletL = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("com/msb/Images/bulletL.gif"));
            BulletR = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("com/msb/Images/bulletR.gif"));
            BulletU = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("com/msb/Images/bulletU.gif"));
            BulletD = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("com/msb/Images/bulletD.gif"));
            for (int i = 0; i < 16; i++) {
                explodes[i] = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("com/msb/Images/e" + (i+1) + ".gif"));;
            }

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
